function gt3(i: Ptr[Int]) {
    return *i > 3;
}

function main() {
    printf("original\n");
    var a: Array[Int] = Array[Int].new(4);
    printf("length = %zu\n", a.length);
    a[0] = 11;
    a[1] = 23;
    a[2] = 35;
    a[3] = 47;
    // a = [1, 2, 3, 4];
    printf("first element = %i\n", a[0]);
    printf("second element = %i\n", a[1]);
    printf("third element = %i\n", a[2]);
    printf("fourth element = %i\n", a[3]);
    for x in a {
        printf("iterating: %i\n", x);
    }

    printf("copy\n");
    var a2: Array[Int] = a.copy();
    printf("length = %zu\n", a2.length);
    printf("first element = %i\n", a2[0]);
    printf("third element = %i\n", a2[2]);
    for x in a2 {
        printf("%i\n", x);
    }

    {
        var a1: Array[Int] = Array.new(3);
        a1[0] = 1;
        a1[1] = 3;
        a1[2] = 5;

        var a2: Array[Int] = Array.new(3);
        a2[0] = 5;
        a2[1] = 6;
        a2[2] = 7;

        var a3: Array[Int] = Array.new(3);
        a3[0] = 0;
        a3[1] = 1;
        a3[2] = 2;

        for a in [a1, a2, a3] {
            puts(if a.any(gt3) then "any = true" else "any = false");
            puts(if a.all(gt3) then "all = true" else "all = false");
        }
    }
}
